package dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;

import entity.CityArea;

public class BaseDao {
 private String uri = "jdbc:sqlserver://localhost:1433;DataBaseName=2017_7_21";
 private String d1 = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
 private String Name = "sa";
 private String pwd = "accp";
 private Connection conn = null;
 public Connection getConnection(){
		
		try {
			Class.forName(d1);
			if(conn == null){
				conn = DriverManager.getConnection(uri,Name,pwd);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return conn;
	}
 public void colse(ResultSet re,PreparedStatement tmt,Connection conn)
 {
	 try {
		if(re !=null)
		{
	        re.close();		
		}
		if(tmt !=null)
		{
			tmt.close();
		}
		if(conn != null)
		{conn.close();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
 }

}
